var enable = true;

chrome.browserAction.onClicked.addListener(function(tab) {
	enable = !enable;    
	if(enable){
		chrome.browserAction.setIcon({ path: 'icon.png' });
		chrome.browserAction.setTitle({ title:'Light On\nHide On' });
	}else{
		chrome.browserAction.setIcon({ path: 'icon_disable.png' });
		chrome.browserAction.setTitle({ title:'Light Off\nHide Off' });	
	}
});

function loadJS(activeInfo) {
	if(enable)
    		chrome.tabs.executeScript({ file: "content.js" });
}

chrome.tabs.onUpdated.addListener(loadJS);
chrome.tabs.onActivated.addListener(loadJS);